package com.qf.controller;

import com.qf.annotation.Log;
import com.qf.entity.YuYueOrder;
import com.qf.entity.YuYueOrderDTO;
import com.qf.service.YuYueOrderService;
import com.qf.util.R;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * --- 冲 ---
 *
 * @author Biggen
 * @date 2025/4/27
 * @desc
 */
@RestController
@CrossOrigin
@RequestMapping("/zf")
public class YuYueOrderController {
    private Logger logger = LogManager.getLogger(YuYueOrderController.class);

    @Autowired
    private YuYueOrderService service;

    @GetMapping("/order/delete/{id}")
    public R YuYueOrderDelete(@PathVariable("id") int id){
        boolean okk = service.YuYueOrderDelete(id);
        return R.ok(okk);
    }

    @GetMapping("/order/num")
    @Log(value = "查询预约订单号", type = "查询")
    public R getOrderNum(){
        List<YuYueOrder> orderNum = service.getOrderNum();
        return R.ok(orderNum);
    }

    @GetMapping("/order/delete/all")
    public R YuYueOrderDeleteAll(@RequestParam("ids") List<Integer> ids){
        boolean okk = service.YuYueOrderDeleteAll(ids);
        return R.ok(okk);
    }


    @PostMapping("/order/update")
    @Log(value = "修改预约订单", type = "修改")
    public R YuYueOrderUpdate(@RequestBody YuYueOrder yuYueOrder){
        boolean okk = service.YuYueOrderUpdate(yuYueOrder);
        return R.ok(okk);
    }

    @PostMapping("/order/add")
    @Log(value = "新增预约订单", type = "新增")
    public R YuYueOrderAdd(@RequestBody YuYueOrder yuYueOrder){
        boolean okk = service.YuYueOrderAdd(yuYueOrder);
        return R.ok(okk);
    }



    @GetMapping("/order/getStatusRate")
    public R GetStatusRate(){
        List<HashMap<String, Object>> list = service.getStatusRate();
        HashMap<String, Integer> data = new HashMap<>();
        data.put("Y", 0);
        data.put("N", 0);
        for (Map<String, Object> map : list) {
            String status = (String) map.get("status");
            Integer num = ((Number) map.get("num")).intValue();
            data.put(status, num);
        }
        return R.ok(data);
    }

}















